<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<link rel="stylesheet" th:href="@{/assets/css/colorbox.css}" />
<head th:include="fragments/head::header" />
<style>
	.error {
		color: #F00
	}
</style>
<body>
<div th:include="fragments/top::top"></div>
<div class="main-container" id="main-container">
	<div class="main-container-inner">
		<div th:include="fragments/left::left" class="sidebar" id="sidebar"></div>
		<div class="main-content">
			<div class="breadcrumbs" id="breadcrumbs">
				<ul class="breadcrumb">
					<li>学生列表</li>
					<li>后续管理</li>
				</ul>
			</div>

			<div class="page-content">
				<div class="row">
					<div class="col-xs-12">
						<div class="row">
							<div class="col-xs-12">
								<div th:include="fragments/student_info::student_info" th:style="${session.studentInfoKey == null}? 'display:none'"></div>
								<h3 class="header smaller lighter blue">后续申请列表</h3>
								<input type="hidden" id="visaRecordAuditStatus" th:value="${visaRecordAuditStatus}" />
								<input type="hidden" name="studentNo" id="studentNo" th:value="${#httpServletRequest.getParameter('studentNo')}"/>
								<input type="hidden" id="oaid" th:value="${session.user.oaid}" />
								<div class="table-header">
									<form class="form-inline">
										<div class="form-group">
											<label>后续类型：</label>
											<select type="" class="form-control input-sm" id="visitType" style="width:100px;">
												<option value="" selected="selected">-全部-</option>
												<option value="1">接机</option>
												<option value="2">保险</option>
												<option value="3">监护</option>
												<option value="4">主课住宿</option>
												<option value="5">语言住宿</option>
											</select>
											<!--<input type="text" id="value" class="form-control input-sm" placeholder="" style="width:100px;"/>-->
										</div>
										<div class="form-group">
											<label>申请状态：</label>
											<select type="" class="form-control input-sm" id="applyStatus" style="width:100px;">
												<option value="" selected="selected">-全部-</option>
												<option value="1">等待确认</option>
												<option value="2">已收到offer结果</option>
												<option value="3">已拒绝</option>
											</select>
										</div>
										<button type="button" id="query" class="btn btn-success ">查询</button>
										<button type="reset" class="btn btn-warning">清空</button>
										<shiro:hasPermission name="后续申请_添加">
											<a data-toggle="modal" data-target="#myModal" href="javascript:void(0);" onclick="toAddUrl();"
											   class="btn btn-info pull-right">添加后续申请</a>
										</shiro:hasPermission>
										<a data-toggle="modal" data-target="#myModal" href="javascript:void(0);" onclick="toStudentListUrl();"
										   class="btn btn-info pull-right">学生列表</a>
									</form>
								</div>
								<shiro:hasPermission name="后续申请_查看">
									<input type="hidden" name="permission_select" id="permission_select" value="1"/>
								</shiro:hasPermission>
								<shiro:hasPermission name="后续申请_修改">
									<input type="hidden" name="permission_select" id="permission_update" value="1"/>
								</shiro:hasPermission>
								<shiro:hasPermission name="后续申请_修改">
									<input type="hidden" name="permission_delete" id="permission_delete" value="1"/>
								</shiro:hasPermission>
								<shiro:hasPermission name="后续申请_offer结果">
									<input type="hidden" name="permission_select" id="permission_offer" value="1"/>
								</shiro:hasPermission>
								<div class="table-responsive">
									<div id="alert" class="alert alert-success" style="display: none;" role="alert">
										<button type="button" class="close" data-dismiss="alert" aria-label="Close">
											<span aria-hidden="true">&times;</span>
										</button>
										<span id="alertText"></span>
									</div>
									<table id="sample-table-2" class="table table-striped table-bordered table-hover">
										<thead>
										<tr>
											<th>申请状态</th>
											<th>后续类型</th>
											<th>合作机构</th>
											<th>提交人</th>
											<th>操作日期</th>
											<th>回访</th>
											<th class="hidden-480">操作</th>
										</tr>
										</thead>
									</table>
								</div>
							</div>
						</div>
					</div>
					<!-- /.col -->
				</div>
				<!-- /.row -->
			</div>
			<!-- /.page-content -->
		</div>

		<div th:include="fragments/bottom::bottom"></div>
	</div>

	<a href="#" id="btn-scroll-up"
	   class="btn-scroll-up btn btn-sm btn-inverse"> <i
			class="icon-double-angle-up icon-only bigger-110"></i>
	</a>
</div>
<!-- /.main-container -->

<!-- Modal备注 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
	 aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content"></div>
	</div>
</div>
<div th:include="fragments/js::js"></div>

<script th:src="@{/assets/js/jquery.validate.min.js}"></script>
<script th:src="@{/assets/js/jquery.validate.zh-CN.js}"></script>
<!-- page specific plugin scripts -->
<script th:src="@{/assets/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/assets/js/jquery.dataTables.bootstrap.js}"></script>
<script th:src="@{/assets/js/temp.js}" charset="UTF-8"></script>
<script th:src="@{/business/followService/followService.js}" charset="UTF-8"></script>
<!--图片查看器-->
<script th:src="@{/assets/js/jquery.colorbox-min.js}"></script>
<script th:src="@{/layer/layer.js}"></script>
<script type="text/javascript">
	var offerResult='';
    var oTable1;
    var visaRecordAuditStatus = $("#visaRecordAuditStatus").val();
    console.log(visaRecordAuditStatus);
    jQuery(function($) {
        oTable1 = $('#sample-table-2').dataTable({
            "bFilter" : false,//是否使用搜索
            "bProcessing" : true,
            "bDeferRender" : true,//
            "sPaginationType" : "bs_normal",//分页样式
            "bRetrieve" : true,//是否调用后台
            "bServerSide" : true,//是否以后台分页
            "bAutoWidth": true,
            "sAjaxSource" : "/followService/list/data",//请求路径
            "fnServerData" : function(sSource, aoData, fnCallback) {
                aoData.push(
                    {"name":"applyStatus","value":$("#applyStatus").val()!=""? $("#applyStatus").val():null},
                    {"name":"visitType","value":$("#visitType").val()!=""? $("#visitType").val():null},
                    {"name":"studentNo","value":$("#studentNo").val()}
                )
                $.ajax({
                    "dataType" : 'json',
                    "type" : "GET",
                    "url" : sSource,
                    "data" : aoData,
                    "success" : fnCallback
                });
            },
            "aaSorting" : [ [ 0, "desc" ] ],
			"bSort":true,
            "aoColumns" : [
                {"sClass": "center", "bSortable": false, "mData":
                	function (data) {
                		if(data.applyStatus == 1) return "等待确认";
                		if(data.applyStatus == 2) return "已收到offer结果";
                        if(data.applyStatus == 3) return "已拒绝";
                		return "";
                	}},
                {"sClass": "center", "bSortable": false, "mData":
                    function (data) {
                        if (data.visitType == 1) {
                            offerResult="接机信息"
                            return "接机"
                        };
                        if (data.visitType == 2) {
                            offerResult="保险单"
                            return "保险";
                        }
                        if (data.visitType == 3){
                            offerResult="监护信息"
                            return "监护";
                        }
                        if (data.visitType == 4) {
                            offerResult="主课住宿"
                            return "主课住宿";
                        }
                        if (data.visitType == 5) {
                            offerResult="语言住宿"
                            return "语言住宿";
                        }
                        return "";
                    }},
                {"sClass": "center", "bSortable": false,"mData":
                	function (data) {
                		return data.agencyName;
                	}},
                {"sClass": "center", "bSortable": false, "mData": "operatorName"},
                {"sClass": "center", "bSortable": false, "mData": "applyDate"},
                {"sClass": "center", "bSortable": false, "mData":
                	function (data) {
                        var styleDiv='<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">';
                        var visitOperation= '<a class="green" href="javascript:void(0);" onclick="toVisitURL('+data.id+')">\n' +
                            '<i class="icon-pencil bigger-130"></i></a>\n' +
                            '</div>';
                        return styleDiv+visitOperation;
                	}},
                {"sClass" : "center","sWidth":"30%",   "bSortable" : false, "mData" : function (data) {
                    var edit_select = '';
                    var edit_update = '';
                    var edit_offer = '';
                    var edit_delete = '';
                    if($("#permission_select").val() ==1){
                         edit_select = '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="toDetailPage(' + data.id + ')" >详情</a>&nbsp;&nbsp;';
					}
                    if($("#permission_update").val() ==1){
                         edit_update	= '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="toEditPage(' + data.id + ')" >修改</a>&nbsp;&nbsp;';
					}

                        //edit_delete	= '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="toDeletePage(' + data.id + ')" >删除</a>&nbsp;&nbsp;';
                    if($("#permission_offer").val() ==1){
                         edit_offer =  '&nbsp;&nbsp;<a href="javascript:void(0);" onclick="toResultListPage(' + data.id + ')" >'+offerResult+'</a>&nbsp;&nbsp;';
					}
					/*<![CDATA[*/
					if((data.visitType == 3 && visaRecordAuditStatus) || $("#oaid").val() != data.operatorNo){
						return edit_select+edit_offer+edit_delete;
					}
					/*]]>*/
                    return edit_select+edit_update+edit_offer+edit_delete;
                }}
            ],
            "oLanguage" : {
                "sLengthMenu" : "每页 _MENU_条 ",
                "sZeroRecords" : "对不起，查询不到任何相关数据",
                "sInfo" : "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录 ",
                "sInfoEmpty" : "显示 0 到 0 条，共 0 条记录",
                "sInfoFiltered" : "数据表中共为 _MAX_ 条记录)",
                "sProcessing" : "正在加载中...",
                "sSearch" : "搜索",
                "sUrl" : "", //多语言配置文件，可将oLanguage的设置放在一个txt文件中，例：Javascript/datatable/dtCH.txt
                "oPaginate" : {
                    "sFirst" : "第一页",
                    "sPrevious" : " 上一页 ",
                    "sNext" : " 下一页 ",
                    "sLast" : " 最后一页 "
                }
            }
            //多语言配置

        });

        $("#query").click(function() {
            oTable1.fnDraw();
        })

    })

	//跳转到添加页面
function toAddUrl(){
	location.href="/followService/addPage?studentNo="+$("#studentNo").val();
}

function toStudentListUrl() {
    location.href="/studentInfo";
}

//返回学生列表
function toStudentListUrl() {
    location.href="/studentInfo";
}

//回访
function toVisitURL(id){
	var studentNo = $('#studentNo').val();
	/*<![CDATA[*/
	location.href="/visit?studentNo="+studentNo+"&visitCase=3&businessId="+id;
	/*]]>*/
}

</script>
</body>
</html>
